package cn.itfei.lottery.domain.strategy.service.draw;

import cn.itfei.lottery.common.Constants;
import cn.itfei.lottery.domain.strategy.service.algorithm.IDrawAlgorithm;
import org.springframework.beans.factory.annotation.Autowired;


import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @description:    抽奖统一配置类
 * @author：hfb
 * @date: 2023/11/8
 */
public class DrawConfig {

    @Resource(name = "singleRateRandomDrawAlgorithm")
    private IDrawAlgorithm SingleRateRandomDrawAlgorithm;
    @Resource(name = "entiretyRateRandomDrawAlgorithm")
    private IDrawAlgorithm EntiretyRateRandomDrawAlgorithm;

    /** 抽奖策略组 */
    protected static Map<Integer, IDrawAlgorithm> drawAlgorithmGroup = new ConcurrentHashMap<>();

    @PostConstruct
    public void init(){
        drawAlgorithmGroup.put(Constants.StrategyMode.ENTIRETY.getCode(), EntiretyRateRandomDrawAlgorithm);
        drawAlgorithmGroup.put(Constants.StrategyMode.SINGLE.getCode(), SingleRateRandomDrawAlgorithm);
    }
}
